﻿using System;
using System.Web.UI;

using OctoOS.UI;

/// <summary>
/// Summary description for ArticleUIPreview
/// </summary>
public class CategoryArticleUIPreview : BaseArticleUIPreview
{
	CategoryArticlePreview _preview;

	public CategoryArticleUIPreview(CategoryArticlePreview preview)
		: base(preview.Featured)
	{
		_preview = preview;
		HeaderText = preview.Title;
		ImageUrl = "/images/article.gif";
		HeaderUrl = Urls.GetArticle(preview.ID, false, false, preview.Title);
		Body = new Literal(preview.Preface);
	}

	protected override void RenderFooterContent(HtmlTextWriter writer)
	{
		writer.Write("<span");
		writer.WriteAttribute("style", "color:black");
		writer.Write(">");
		writer.WriteEncodedText(Resources.Main.shared_Author + ": " + _preview.Author);
		writer.Write("</span><br/>");

		writer.Write("<span>");
		writer.WriteEncodedText(Resources.Main.shared_Published + " ");

		var t = new Time(_preview.PublishStartTime.ToLocalTime());
		t.RenderControl(writer);

		if(_preview.PublishStopTime != DateTime.MaxValue)
		{
			writer.Write("<br/>");
			writer.Write(Resources.Main.shared_PublishStops + " ");
			writer.Write(_preview.PublishStopTime.ToShortDateString());
		}

		writer.Write("</span>");
	}
}